package pCloud.service;

import pCloud.message.Message;
import pCloud.message.NumberMessage;

/**
 * Handle messages sent from the proxy back to the client
 * 
 */
public class ClientProxyServerProtHandle extends ProtocolHandle {

	int counter = 0; 
	@Override
	public void receive(Object o) throws Exception {
		handleProxyReplyMessage((Message) o);
		
//		this.conn.close();
//		this.communicator.removeConnection(this); 
	}

	@Override
	public void send(Object m) throws Exception {
		conn.send(m);
	}

	private void handleProxyReplyMessage(Message m) {
		if (m.getMessageType() != Message.PROXY_TO_CLIEN_MSG) {
			System.err
					.println("PROXY_TO_CLIENT message expected, wrong type received "
							+ m.getMessageType());
			return;
		}
		this.communicator.getLogger().debug(m.getMessageContent() + " from " + m.getFrom());
		System.out.println("From "+m.getFrom());
		System.out.println("Time = "+System.currentTimeMillis());
		System.out.println(m.getMessageContent());
	}
}
